package module

import (
	"demo_test/webservice_demo/util"
	"log"
)

type User struct {
	Id       int    `json:"id"`
	UserName string `json:"user_name"`
	Pwd      string `json:"pwd"`
}

func (u *User) AddUser() error {
	sqlstr := "insert into users(user_name,pwd) values (?,?)"
	stmtIn, err := util.DBConn.Prepare(sqlstr)
	if err != nil {
		log.Print("数据库准备出现错误")
		return err
	}

	stmtIn.Exec(u.UserName, u.Pwd)
	stmtIn.Close()
	return nil

}
